package com.hjm.project.salaryPlan.agentActivityOpen.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.salaryPlan.agentActivityOpen.domain.AgentActivityOpen;
import com.hjm.project.salaryPlan.agentActivityOpen.service.IAgentActivityOpenService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import javax.annotation.Resource;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 开通底薪计划代理Controller
 * 
 * @author maker-platform
 * @date 2022-04-07
 */
@Controller
@RequestMapping("/salaryPlan/agentActivityOpen")
public class AgentActivityOpenController extends BaseController {
    private String prefix = "salaryPlan/agentActivityOpen";

    @Resource
    private IAgentActivityOpenService agentActivityOpenService;

    @RequiresPermissions("salaryPlan:agentActivityOpen:view")
    @GetMapping()
    public String agentActivityOpen() {
        return prefix + "/agentActivityOpen";
    }

    /**
     * 查询开通底薪计划代理列表
     */
    @RequiresPermissions("salaryPlan:agentActivityOpen:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AgentActivityOpen agentActivityOpen) {
        startPage();
        List<AgentActivityOpen> list = agentActivityOpenService.selectAgentActivityOpenList(agentActivityOpen);
        return getDataTable(list);
    }

    /**
     * 导出开通底薪计划代理列表
     */
    @RequiresPermissions("salaryPlan:agentActivityOpen:export")
    @Log(title = "开通底薪计划代理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AgentActivityOpen agentActivityOpen) {
        List<AgentActivityOpen> list = agentActivityOpenService.selectAgentActivityOpenList(agentActivityOpen);
        ExcelUtil<AgentActivityOpen> util = new ExcelUtil<AgentActivityOpen>(AgentActivityOpen.class);
        return util.exportExcel(list, "agentActivityOpen");
    }

    /**
     * 新增开通底薪计划代理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存开通底薪计划代理
     */
    @RequiresPermissions("salaryPlan:agentActivityOpen:add")
    @Log(title = "开通底薪计划代理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AgentActivityOpen agentActivityOpen) {
        return toAjax(agentActivityOpenService.insertAgentActivityOpen(agentActivityOpen));
    }

    /**
     * 修改开通底薪计划代理
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap) {
        AgentActivityOpen agentActivityOpen = agentActivityOpenService.selectAgentActivityOpenById(id);
        mmap.put("agentActivityOpen", agentActivityOpen);
        return prefix + "/edit";
    }

    /**
     * 修改保存开通底薪计划代理
     */
    @RequiresPermissions("salaryPlan:agentActivityOpen:edit")
    @Log(title = "开通底薪计划代理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AgentActivityOpen agentActivityOpen) {
        return toAjax(agentActivityOpenService.updateAgentActivityOpen(agentActivityOpen));
    }

    /**
     * 删除开通底薪计划代理
     */
    @RequiresPermissions("salaryPlan:agentActivityOpen:remove")
    @Log(title = "开通底薪计划代理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(agentActivityOpenService.deleteAgentActivityOpenByIds(ids));
    }
}
